package com.wlc.base;

import java.util.Arrays;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.List;
import java.util.concurrent.ConcurrentHashMap;

public class HelloWrld {

    public void method01() {
        int[] a = new int[]{18, 62, 68, 82, 65, 9};

        // original: 源数组   from 从原数组复制的起始位置   to  源数组复制的长度
        int[] ints = Arrays.copyOfRange(a, 0, 2);
        // Arrays.toString(array) 把数组转换为字符串
        System.out.println(Arrays.toString(ints));

        // 排序 Arrays.sort()
        Arrays.sort(a);
        System.out.println(Arrays.toString(a));

        // 搜索 Arrays.binarySearch(数组，关键字） 如果查不到，返回负数； 如果查找到，返回 关键字 出现的位置
        int result = Arrays.binarySearch(a, 62);
        System.out.println("result = " + result);

        int[] b = new int[]{18, 62, 68, 82, 65, 9};
        int[] c = {1, 62, 68, 82, 65, 9};
        // 比较数组是否相等  Arrays.equals(int[] a,int[] b)
        boolean equals = Arrays.equals(c, b);
        System.out.println("equals = " + equals);
        // 使用同一数字，填充数组  fill(要填充的数组，开始的下标，结束的下标，填充的数字)  [fromIndex,toIndex)
        Arrays.fill(c, 0, 3, 66);
        System.out.println("Arrays.toString(c) = " + Arrays.toString(c));
    }

    public void method02() {
        int[] b = new int[]{18, 62, 68, 82, 65, 9};
        List<int[]> ints = Arrays.asList(b);
        ints.stream().forEach(System.out::print);

    }

    public void method03() {
        System.out.println("hello world ");
    }

    public void method04(){
        Hashtable hashtable = new Hashtable();
        hashtable.put("abc","hello");
        HashMap hashMap = new HashMap();
        hashMap.put("abc","hello");

        ConcurrentHashMap concurrentHashMap = new ConcurrentHashMap();
        concurrentHashMap.put("a","1");
        System.out.println("concurrentHashMap.get(\"a\") = " + concurrentHashMap.get("a"));
    }
    public static void main(String[] args) {
        new HelloWrld().method04();
    }
}